package com.eascs.spider.hr.common.controller;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import com.eascs.app.log.Logger;
import com.eascs.app.log.LoggerFactory;
import com.eascs.common.assertion.exception.InfoAssertionException;
import com.eascs.common.assertion.exception.WarnAssertionException;
import com.eascs.site.controller.BaseRestController;
import com.eascs.site.view.BaseRestResult;

public abstract class BaseActionRestController extends BaseRestController {

	private final Logger logger = LoggerFactory.getLogger(BaseActionRestController.class);

	@ExceptionHandler
	@ResponseBody
	@Override
	public Object exception(WarnAssertionException warnAssertionException) {
		logger.info(warnAssertionException.getMessage(), warnAssertionException);
		return BaseRestResult.warn(warnAssertionException.getMessage());
	}

	@ExceptionHandler
	@ResponseBody
	@Override
	public Object exception(InfoAssertionException infoAssertionException) {
		logger.info(infoAssertionException.getMessage(), infoAssertionException);
		return BaseRestResult.warn(infoAssertionException.getMessage());
	}

}